package com.hyp.controller;

import com.hyp.pojo.*;
import com.hyp.service.AddressService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@Slf4j //显示日志消息
@RestController
@RequestMapping("/wx/")
public class AddressController {
    @Autowired
    private AddressService addressService;

    @PostMapping("/addressAdd")
    public Result addressAdd(@RequestBody Address address){
        addressService.addressAdd(address);
        return Result.success(address);
    }

    @GetMapping("/addresslist/{userId}")
    public Result addresslist(@PathVariable Integer userId){
        List<Address> addresslist = addressService.list(userId);
        return Result.success(addresslist);
    }

    @GetMapping("/addressById/{addressId}")
    public Result addressById(@PathVariable Integer addressId){
        Address address = addressService.addressById(addressId);
        return Result.success(address);
    }
}
